<template>
	<view class="container">
		<view class="header">
			<text>{{data.title}}</text>
		</view>
		<view class="footer">
			<view><text>{{data.date}}</text></view>
		</view>
		<view class="content">
			<u-parse :content="data.content"></u-parse>
			<!-- <text>{{data.content}}</text> -->
		</view>


	</view>
</template>

<script>
	import {
		getNoticeInfo
	} from "@/api/user.js"
	export default {
		data() {
			return {
				data: {}
			};
		},
		onLoad(options) {
			const noticeid = options.noticeid;
			console.log('noticeid:', noticeid);
			// 进行后续操作
			this.getNoticeDetials(noticeid)
		},
		methods: {
			formatData(data) {
				const date = new Date(data.updateTime);
				const timeFormat = uni.$u.timeFormat;
				let timeValue = timeFormat(date, 'yyyy-mm-dd hh:MM:ss');
				return {
					title: data.title,
					content: data.content,
					date: timeValue,
				};
			},
			getNoticeDetials(noticeid) {
				getNoticeInfo(noticeid).then(res => {
					console.log("res: " + JSON.stringify(res));
					this.data = this.formatData(res.data)
					console.log("this.data: " + JSON.stringify(this.data));

				}).catch(err => {

				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.container {
		margin: 10px 10px;
		border-radius: 6px;
		background-color: #fff;
		padding: 10px 10px;

		.header {
			text-align: left;
			font-size: 36rpx;
			font-family: PingFangSC-Semibold, PingFang SC;
			font-weight: 600;
			color: #3A3D4B;
			line-height: 56rpx;
			word-wrap: break-word;
		}

		.content {
			margin-top: 32rpx;
			margin-bottom: 60rpx;
			width: 100%;
			word-wrap: break-word;

			font-size: 28rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #3A3D4B;
			line-height: 40rpx;
		}

		.footer {
			margin-top: 20rpx;

			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #99A1AF;
			line-height: 34rpx;
		}
	}
</style>